#pragma once

#include <linux/compiler.h>
#include <linux/threads.h>
#include <linux/percpu-defs.h>
#include <linux/preempt.h>
#include <linux/smp.h>
#include <asm/processor.h>

#define per_cpu(var, cpu) (*per_cpu_ptr(&(var), cpu))

extern void setup_per_cpu_areas(void);

extern void *pcpu_alloc_noprof(size_t size, size_t align, bool reserved, gfp_t gfp);

#define __alloc_percpu(_size, _align) \
    pcpu_alloc_noprof(_size, _align, false, GFP_KERNEL)

#define alloc_percpu(type)                       \
    (typeof(type) *)__alloc_percpu(sizeof(type), \
                                   __alignof__(type))
